#pragma once

#include "zen_vap_helper.h"
#include "zen_vap_node.h"
#include "zen_vap_texture.h"
#include "zen_point.h"
#include <vector>
#include <mutex>

namespace Zen { namespace Vap {

	/*!
	 @class Sprite
	 @abstract This is the sprite that render a rect texture.
	 */
	class Sprite
	: public Node2D, public PartOfMatrix2D
	, public PartOfColor, public PartOfFlip
	, public PartOfTexture
	{
	public:
		Sprite(std::string const & name = "sprite");

		/*!
		 @function
		 @abstract set the fixed size of content. (if not enabled, this has no effect)
		 */
		void setContentSize(Size2 size);

		void setContentSizeWithWidth(float w);

		void setContentSizeWithHeight(float h);

		void setContentSize();
		/*!
		 @function
		 @abstract get the content size. <br>
		 if fixed size enabled, this will return the fixed size. <br>
		 otherwise this is the texture's size (scaled).
		 */
		Size2 getContentSize();

		void updateContent();

		virtual void load() override;

		virtual void ready() override;

		virtual void draw() override;

#if ZEN_APP_GLES
	public:
		/*!
		 @function
		 @abstract set the shader selector. <br>
		 see ref class ShaderKit
		 */
		void setShaderSelector(GL::ShaderKitTexture::Selector s) { m_shader_selector = s; }

		auto getShaderSelector() { return m_shader_selector; }

	protected:
//		static GL::DrawBufferTexture s_gl_buffer;
		GL::ShaderKitTexture::Selector m_shader_selector;
#endif

	protected:
		Vec4 m_texture_rect_converted = { 0, 0, 1, 1 };

		/// texture.
		Size2 m_fixed_size = { 0, 0 };
		/// use m_fixed_size or m_texture_size as content size.
		bool m_is_fixed_sized = false;
	};
}}
